#ifndef LINE_H
#define LINE_H

const int ADJ_THRESH = 15;
const double PERP_THRESH = PI/16; // 
const double PAR_THRESH = PI/8; // 

double G_MEANS[3];
double C_MEANS[3];

class Line {
    int id;
    int *linePoints; // [end1, end2, mid] as addr (not coord)
    double *depths;
    double orientation, length;
    public:
    Line(){}
    Line(int id, double orientation, double length, int end1, int end2, int mid, double *depths);
    int getId();
    double getOrientation();
    double getLength();
    double *getDepths();
    int *getPoints();
};

//----------LineGroup (L)----------//

bool checkAdj(int *line1_points, int *line2_points);
bool checkPerp(double line1_orient, double line2_orient);
bool checkPar(int posInfo, double line1_orient, double line2_orient);
//bool checkBehind(Line line1, Line line2); //TODO: make this. Do I need it, actually?
int getPosInfo(int *line1_points, int *line2_points);
void linesFromLSRs(Line *Lines, LSR *LSRs, bool isGoal);

class LineGroup {
    int n_lines;
    Line *Lines;
    //These boolean arrays are the 'relationship matrices'
    bool *R_adj;  //reciprocal
    bool *R_perp; //reciprocal
    bool *R_par;  //reciprocal
    bool *R_above;   //NOT reciprocal
    bool *R_left;  //NOT reciprocal
    //double *a_means; // [meanPoint, meanOrientation, meanLength] NOTE: cast meanPoint to int
    public:
    LineGroup(){};
    LineGroup(Line *Lines, bool isGoal);
    int getN_lines();
    Line *getLines();
    Line getLineAt(int index);
    bool *getR_adj();
    bool *getR_perp();    
    bool *getR_par();
    bool *getR_above();
    bool *getR_left();
    //double *getA_means();
    int relAddr(int line1, int line2); //given lines, gets rel address
    int *relLines(int addr); //given rel address, gets lines
};

void drawL(LineGroup target, char *log_path, Mat cleanImg, bool isGoal);

#endif
